package com.UnionPayCenter.operation.enums;

import com.UnionPayCenter.enums.CodeBaseEnum;
import com.UnionPayCenter.exception.ApiException;

/**
 * 运营活动操作类型
 */
public enum ActivityOperationTypeEnum implements CodeBaseEnum {

    //1--充值, 2--余额支付,3--现金支付, 4--注册

    /**
     * 优惠券
     */
    CHARGE(1, "充值"),

    /**
     * 现金券，直接充值到赠送账户
     */
    PAY(2, "现金支付"),

    /**
     * 余额支付
     */
    BALANCE_PAY(3, "余额支付"),
    /**
     * 优惠券
     */
    REGIST(4, "注册"),

    ;

    private int code;

    private String msg;


    ActivityOperationTypeEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static ActivityOperationTypeEnum getEnum(int code) {
        for (ActivityOperationTypeEnum ele : ActivityOperationTypeEnum.values()) {
            if (ele.code == code) {
                return ele;
            }
        }
        throw new ApiException(404, "不正确的活动奖励类型");
    }

    @Override
    public int code() {
        return this.code;
    }

    @Override
    public String msg() {
        return msg;
    }
}
